import java.util.ArrayList;
import java.util.List;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-03-22
 * Time:20:28
 */class Node {
    public int val;
    public List<N> children;

    public Node() {}

    public Node(int _val) {
        val = _val;
    }

    public Node(int _val, List<N> _children) {
        val = _val;
        children = _children;
    }
};
public class N叉树的前序遍历 {

    class Solution {
        List<Integer> list = new ArrayList<>();
        public List<Integer> preorder(N root) {

            if(root == null) {
                return list;
            }
            list.add(root.val);
            for (N child : root.children) {
                preorder(child);
            }
            return list;
        }
    }

}
